﻿using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Linq;
using System.Text;

namespace DanTriNews.ViewModels
{
    public class NewsViewModel : INotifyPropertyChanged
    {
        public NewsViewModel(int id,string title,string imageurl,string detailUrl,string date)
        {
            Id = id;
            Title = title;
            ImageUrl = imageurl;
            DetailUrl = detailUrl;
            NewsContent = "";
            Date = date;
        }
        private int _id;
        public int Id
        {
            get
            {
                return _id;
            }
            set
            {
                if (value != _id)
                {
                    _id = value;
                    NotifyPropertyChanged("Id");
                }
            }
        }
        private string _title;
        public string Title
        {
            get
            {
                return _title;
            }
            set
            {
                if (value != _title)
                {
                    _title = value;
                    NotifyPropertyChanged("Title");
                }
            }
        }
        private string _imageUrl;
        public string ImageUrl
        {
            get
            {
                return _imageUrl;
            }
            set
            {
                if (value != _imageUrl)
                {
                    _imageUrl = value;
                    NotifyPropertyChanged("ImageUrl");
                }
            }
        }
        private string _detailUrl;
        public string DetailUrl
        {
            get
            {
                return _detailUrl;
            }
            set
            {
                if (value != _detailUrl)
                {
                    _detailUrl = value;
                    NotifyPropertyChanged("DetailUrl");
                }
            }
        }
        private string _newsContent;
        public string NewsContent
        {
            get
            {
                return _newsContent;
            }
            set
            {
                if (value != _newsContent)
                {
                    _newsContent = value;
                    NotifyPropertyChanged("NewsContent");
                }
            }
        }

        private string _date;
        public string Date
        {
            get
            {
                return _date;
            }
            set
            {
                if (value != _date)
                {
                    _date = value;
                    NotifyPropertyChanged("Date");
                }
            }
        }
        public event PropertyChangedEventHandler PropertyChanged;
        private void NotifyPropertyChanged(String propertyName)
        {
            PropertyChangedEventHandler handler = PropertyChanged;
            if (null != handler)
            {
                handler(this, new PropertyChangedEventArgs(propertyName));
            }
        }
    }
}
